<?php
header('Content-type: text/xml');
require_once('../../isa-lib/nusoap/nusoap.php');
include "../../isa-lib/isa-function/isa_public_function.php";
include "../../onegate_function.php";
include "../../db_const.php";
include "../../isa-lib/adodb/adodb.inc.php";
include "../../isa-lib/isa-function/prax.php";
include "../../connect_ado.php";
include "../../connect.php";
include "rss_function.php";
include "const.php";
include "qry_all_cate.php";
include "qry_all_qa_question.php";

//var_dump($arr_all_cate);
$v_cate_name = '';
for ($i=0;$i<sizeof($arr_all_cate);$i++){
	if ($arr_all_cate[$i]['0'] == $v_cate_id){
		$v_cate_name = $arr_all_cate[$i]['2'];
		break;
	}
}

$strXML = '<?xml version="1.0" encoding="utf-8"?><rss version="2.0">';
$strXML = $strXML . '<channel>';
$strXML = $strXML . '<title>'.$v_cate_name.'</title>';
$strXML = $strXML . '<link>'._get_current_website_path().'/front-end/qa/index.php?fuseaction=DISPLAY_ALL_QA_BY_CATE&amp;hdn_cate_id='.$v_cate_id.'</link>';
$strXML = $strXML . '<description></description>';
$strXML = $strXML . '<category></category>';
for($v_index = 0; $v_index < sizeof($arr_all_onegate_qa) ; $v_index++){
	$v_qa_id = $arr_all_onegate_qa[$v_index]['PK_QA'];
	$v_qa_title = $arr_all_onegate_qa[$v_index]['C_QUESTION_TITLE'];
	$strXML = $strXML . '<item>';
	$strXML = $strXML . '<title>'.$v_qa_title.'</title>';
	$strXML = $strXML . '<link>'._get_current_website_path().'/front-end/qa/index.php?fuseaction=DISPLAY_SINGLE_QA_QUESTION&amp;qa_id='.$v_qa_id.'&amp;cate_type=CATE</link>';
	$strXML = $strXML . '<description></description>';
	$strXML = $strXML . '<html_content></html_content>';
	$strXML = $strXML . '<file_content></file_content>';
	$strXML = $strXML . '</item>';
}
$strXML = $strXML . '</channel>';
$strXML = $strXML . '</rss>';
print($strXML);
//Ham tra ve duong dan dang ung dung
function _get_current_website_path(){
	global $_SERVER;
	$v_website_path = $_SERVER["SCRIPT_NAME"];
	$arr_website_path = explode("/",$v_website_path);
	if ($arr_website_path[1]!=""){
		$v_current_website_path = 'http://'.$_SERVER['HTTP_HOST'].'/'.$arr_website_path[1];
	}else{
		$v_current_website_path = 'http://'.$_SERVER['HTTP_HOST'];
	}
	return $v_current_website_path;
}
?>